/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package top.dzygod.modules.pay.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

/**
* @website https://dzygod.top
* @description /
* @author dzygod
* @date 2020-07-28
**/
@Entity
@Data
@Table(name="pay_grade")
public class Grade implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "grade_id")
    @ApiModelProperty(value = "年级id")
    private Long id;

    @JoinColumn(name = "school_id")
    @ApiModelProperty(value = "学校id", hidden = true)
    @ManyToOne
    private School school;

    @Column(name = "name")
    @ApiModelProperty(value = "年级名称")
    private String name;

    @Column(name = "gmt_create")
    @CreationTimestamp
    @ApiModelProperty(value = "创建时间")
    private Timestamp gmtCreate;

    @Column(name = "gmt_modified")
    @UpdateTimestamp
    @ApiModelProperty(value = "修改时间")
    private Timestamp gmtModified;

    @OneToMany(mappedBy = "grade")
    @ApiModelProperty(value = "班级集合")
    private List<Class> classList;


    public void copy(Grade source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
